package sjd.ahsj.springbootmybatisplusoracle.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import sjd.ahsj.springbootmybatisplusoracle.entity.AnimeBuy;
import sjd.ahsj.springbootmybatisplusoracle.mapper.AnimeBuyMapper;
import sjd.ahsj.springbootmybatisplusoracle.mapper.BaseUserMapper;
import sjd.ahsj.springbootmybatisplusoracle.service.IAnimeBuyService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 书籍购买 服务实现类
 * </p>
 *
 * @author zhanghaogao
 * @since 2018-09-18
 */
@Service
public class AnimeBuyServiceImpl extends ServiceImpl<AnimeBuyMapper, AnimeBuy> implements IAnimeBuyService {
    @Autowired
    private BaseUserMapper baseUserMapper;

    @Override
    public boolean insert(AnimeBuy entity) {
        if (baseUserMapper.deductionsAmount(entity.getUserId(), entity.getAmount()) < 1) {
            return false;
        }
        return super.insert(entity);
    }
}
